﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the Microsoft Public License (Ms-PL).
// See accompanying file License.txt or copy at http://mews.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Mews.Net.Nntp
{
    using System;
    using System.IO;

    /// <summary>Represents a HEAD command to be sent to an NNTP server, see
    /// <a href="http://www.ietf.org/rfc/rfc3977.txt">RFC 3977</a> 6.2.2.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class HeadCommand : ArticleContentCommand<HeadResponse>
    {
        private const string Command = "HEAD";
        private static readonly string[] successResponseCodes = { "221" };

        /// <summary>Initializes a new instance of the <see cref="HeadCommand"/> class.</summary>
        /// <exception cref="ArgumentNullException"><paramref name="messageId"/> equals <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="messageId"/> contains white space.</exception>
        public HeadCommand(string messageId) : base(Command, messageId, successResponseCodes)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="HeadCommand"/> class.</summary>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="number"/> is smaller than or equal to 0.
        /// </exception>
        public HeadCommand(long number) : base(Command, number, successResponseCodes)
        {
        }

        /// <summary>Initializes a new instance of the <see cref="HeadCommand"/> class.</summary>
        public HeadCommand() : base(Command, successResponseCodes)
        {
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>See <see cref="SingleLineCommandBase{T, U, V, W}.CreateResponse(V, W, Stream)"/>.</summary>
        protected sealed override HeadResponse CreateResponse(long p1, string p2, Stream subsequentLines)
        {
            return new HeadResponse(p1, p2, subsequentLines);
        }
    }
}
